package lablayer.model.MathComponents;

import lablayer.model.LabData;

/*
 * Component #11
 *
 * Recommended number of partition intervals
 */
class PartitionIntervals implements MathComponent {
	private LabData result;

	private LabData data;

	private String componentName = "Число интервалов разбиения";

	private String componentId = "11";

	public PartitionIntervals() {
		super();
		this.result = new LabData();
	}

	@Override
	public LabData getData() {
		return this.data;
	}

	@Override
	public void calculate() {
		try {
			int dataLength = ((this.data.getData())[0][0]).length;
			Double buf = (3.3 * Math.log(dataLength)) + 1;
			
			this.result = new LabData(new Double(buf.intValue() + 1));
		} catch (Exception e) {}		
	}

	@Override
	public void setData(LabData data) {
		if (data != null) {
			this.data = data;
		}
	}

	@Override
	public String getComponentId() {
		return this.componentId;
	}

	@Override
	public String getComponentName() {
		return this.componentName;
	}

	@Override
	public LabData getResult() {
		return this.result;
	}

	@Override
	public void setParameter(String params, String values) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	@Override
	public LabData getInitData() {
		throw new UnsupportedOperationException("Not supported yet.");
	}

}
